#include <iostream>
#include "gameboard.h"


int main()
{
	Gameboard game;
	game.setup();
	char r;
	char c;
	short row;
	short column;
	bool valid;
	
	cout << "O = White" << endl
		 << "@ = Black" << endl
		 << "* = Availble moves" << endl;
		 
	game.showNextPos();
	game.display();

	while (true)
	{
		valid = true;
		
		while(valid)
		{
			cout << game.currentColor() << "'s turn" << endl << endl;
			cout << "type 'u' in row to undo last move" << endl;
			cout << "row: ";
			cin >> r;
			switch(r)
			{
				case '1':
					row = 1;
					valid = false;
					break;
				case '2':
					row = 2;
					valid = false;
					break;
				case '3':
					row = 3;
					valid = false;
					break;
				case '4':
					row = 4;
					valid = false;
					break;
				case '5':
					row = 5;
					valid = false;
					break;
				case '6':
					row = 6;
					valid = false;
					break;
				case '7':
					row = 7;
					valid = false;
					break;
				case '8':
					row = 8;
					valid = false;
					break;
				case 'u':
					game.undo();
					game.showNextPos();
					game.display();
					break;
				default:
					cout << "Sorry that isn't an available row" << endl;
					break;
			}
		}

		valid = true;

		while(valid)
		{
			cout << "column: ";
			cin >> r;
			switch(r)
			{
				case 'a':
					column = 1;
					valid = false;
					break;
				case 'b':
					column = 2;
					valid = false;
					break;
				case 'c':
					column = 3;
					valid = false;
					break;
				case 'd':
					column = 4;
					valid = false;
					break;
				case 'e':
					column = 5;
					valid = false;
					break;
				case 'f':
					column = 6;
					valid = false;
					break;
				case 'g':
					column = 7;
					valid = false;
					break;
				case 'h':
					column = 8;
					valid = false;
					break;
				default:
					cout << "Sorry that isn't an available row" << endl;
					break;
			}
		}

		game.move(row,column);
		game.showNextPos();
		
		if(game.endGame)
			return 0;

		game.display();
	}	
}
